<template>
  <div id="dictTree">
    <el-tree
      highlight-current
      :expand-on-click-node="false"
      default-expand-all
      :data="data"
      @node-click="handleNodeClick">
    </el-tree>
  </div>
</template>

<script>
import { findListByTreeDict } from '@/assets/request/api'
export default {
  name: "dictTree",
  data() {
    return {
      data: [{
        id: 0,
        label: '字典管理',
        type: 0,
        children: []
      }],
    }
  },
  methods: {
    handleNodeClick(data) {
      this.$router.push({'name':"dictManagement"})
      // 获取右侧的tabel
      this.$emit("chooseParentId", {parentId: data.id,type:data.type})
    },
    async initData() {
      await findListByTreeDict().then(res => {
        this.data[0].children = res.data
      }).catch(err => {
        this.$message({
          message: err.message,
          type: 'error'
        });
      })
    }
  },  
  created() {
    this.initData()
  }
}
</script>

<style lang="scss" scoped>

#dictTree {
  margin-top: 20px;
}

</style>
